/*
 * Copyright (c) 2006-2021, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2025-05-13     Administrator       the first version
 */
#include "robot_selectinit.h"

//需要控制的小车类型
void Robot_Select(void)
{
    Car_Mode=0;

    switch(Car_Mode)
    {
        case Mec_Car:       Robot_Init(MEC_wheelspacing,         MEC_axlespacing,  HALL_30F, Hall_13, Mecanum_75);            break; //麦克纳姆轮小车
        case FourWheel_Car: Robot_Init(Four_Mortor_wheelSpacing, Four_Mortor__axlespacing, HALL_30F, Hall_13, Black_WheelDiameter);   break; //四驱车
    }
    rt_kprintf("Choose %d \r\n", Car_Mode);
}


//初始化机器人参数结构体
Robot_Parament_InitTypeDef  Robot_Parament;

//函数功能：初始化小车参数
//入口参数：轮距 轴距 自转半径 电机减速比 电机编码器精度 轮胎直径
void Robot_Init(double wheelspacing, float axlespacing, float gearratio,float Accuracy,float tyre_diameter) //
{
  //轮距 麦轮车为半轮距
  Robot_Parament.WheelSpacing=wheelspacing;  //利用.h里的函数把值赋进去
  //轴距 麦轮车为半轴距
  Robot_Parament.AxleSpacing=axlespacing;
  //电机减速比
  Robot_Parament.GearRatio=gearratio;
  //编码器精度(编码器线数)
  Robot_Parament.EncoderAccuracy=Accuracy;
  //主动轮直径
  Robot_Parament.WheelDiameter=tyre_diameter;
  //电机(车轮)转1圈对应的编码器数值
  Encoder_precision=EncoderMultiples*Robot_Parament.EncoderAccuracy*Robot_Parament.GearRatio;
  //主动轮周长
  Wheel_perimeter=Robot_Parament.WheelDiameter*PI;
  //轮距 麦轮车为半轮距
  Wheel_spacing=Robot_Parament.WheelSpacing;
  //轴距 麦轮车为半轴距
  Axle_spacing=Robot_Parament.AxleSpacing;
}
